package com.chap1;

import com.chap1.tools.SleepTools;

/**
 * <p>
 * <code>VolatileCase</code>
 * </p>
 *
 * @author junbao3
 * TODO
 * @date 2023-03-24 15:58
 * Copyright (C) 2021 IFlyTek. All rights reserved.
 */
public class VolatileCase {
    private volatile static boolean ready;
    private static int number;

    private static class PrintThread extends Thread{
        @Override
        public void run() {
            System.out.println("PrintThread is running.......");
            while (!ready){

            }
            System.out.println("number="+number);
        }
    }

    public static void main(String[] args) {
        new PrintThread().start();
        SleepTools.second(1);
        number = 51;
        ready=true;
        SleepTools.second(5);
        System.out.println("main is ended!");
    }
}
